|
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||
java.lang.Objectcom.prosc.supercontainer.plugin.SCPluginModel
public class SCPluginModel
This class is used to allow any Java code to communicate with a SuperContainer server instance.
This can be used by server-side processes or swing clients.
Some of the methods in this class only work in a swing client (e.g. chooseFile(java.awt.Component, java.io.File, int, java.lang.String) and upload progress bars).
To use the client, you must first call setBaseUrl:
final SCPluginModel model = new SCPluginModel();
final String folderPath = "pictures/123";
final boolean calculateMd5Hash = false;
//
model.setBaseUrl("http://myhost/SuperContainer/Files", "username", "password");
final SCResourceInfo info = model.getResourceInfo(folderPath, calculateMd5Hash);
final File destination = new File("/tmp/" + info.getFilename());
System.out.println("About to download " + folderPath + " (" + info.getContentLength() + " bytes) to " + destination );
final File result = model.download(folderPath, destination, 0, 0, 0, false, true);
System.out.println("File downloaded to " + result + " successfully");
| Field Summary | |
|---|---|
(package private) static byte |
LICENSE_VERSION
|
| Constructor Summary | |
|---|---|
SCPluginModel()
|
|
| Method Summary | |
|---|---|
java.io.File |
chooseFile(java.awt.Component nativeFrame,
FileChooserOptions options)
Convenience method to show a file chooser dialog |
boolean |
clearLocalCache()
Clears any temporary items from the supercontainer_downloads directory. |
void |
delete(java.lang.String folderPath)
Permanently deletes a file from the SuperContainer server |
void |
deleteLocal(java.io.File localFile)
Deletes a local file from the filesystem. |
java.io.File |
download(java.lang.String folderPath,
java.io.File destinationFolderArg,
java.lang.String fileNameOverride,
DownloadParameters parameters,
boolean showProgress,
boolean autoUnzip,
boolean checkIfFileExists,
java.awt.Component nativeFrame)
|
(package private) java.io.File |
getPathToFolderOnServer(java.lang.String macPath,
java.lang.String winPath,
java.lang.String folderPath)
Fetches the stored file's location as a URL pointing to a mounted/mapped file server. |
SCResourceInfo |
getResourceInfo(java.lang.String folderPath)
Returns some information about a given folderPath on the server, without any optional metadata. |
SCResourceInfo |
getResourceInfo(java.lang.String folderPath,
MetadataFlags flags)
Returns some information about a given folderPath on the server, specifying optional MetaDataFlags to be returned by the server. |
java.lang.String |
getSuperContainerBase()
Returns the base URL, as passed to the setBaseUrl(java.lang.String, java.lang.String) function. |
java.lang.String |
getSuperContainerBaseParent()
Returns the parent of the base URL, without the "Files" part. |
void |
move(java.lang.String oldFolderPath,
java.lang.String newFolderPath)
Moves a file on the SuperContainer server without downloading it to the local machine. |
void |
moveLocal(java.io.File sourceFile,
java.io.File destinationFile)
Moves a file locally from one place on server to another local directory. |
SCResourceInfo |
resourceInfoFromHeaders(java.util.Map headers,
java.lang.String path,
MetadataFlags flags)
An alternate means of getting SCResourceInfo if you already have the headers from the server. |
java.util.List |
scanDirectory(java.io.File dir,
boolean recursive)
Scans a directory and returns a list of files. |
void |
setBaseUrl(java.lang.String superContainerBase,
java.lang.String sessionId)
|
void |
setBaseUrl(java.lang.String superContainerBase,
java.lang.String username,
java.lang.String password)
Set the base URL for all subsequent plugin calls. |
void |
setResource(java.lang.String folderPath,
java.io.File file,
boolean showProgress,
java.awt.Component parent)
Uploads a file or directory to SuperContainer |
void |
setResource(java.lang.String folderPath,
java.lang.String fileName,
java.io.InputStream stream,
long length,
boolean showProgress,
java.awt.Component parent,
java.util.Map headers)
Uploads a resource stream to SuperContainer. |
void |
setZipResource(java.lang.String folderPath,
java.lang.String archiveName,
java.io.File[] filesOrDirs,
boolean showProgress,
java.awt.Component parent)
Uploads a file array to SuperContainer by creating a new zip archive named name and uploading to the indicated folderPath. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final byte LICENSE_VERSION
| Constructor Detail |
|---|
public SCPluginModel()
| Method Detail |
|---|
public java.io.File chooseFile(java.awt.Component nativeFrame,
FileChooserOptions options)
nativeFrame - TODOoptions - parameters which alter the behavior of the file chooser dialog
public boolean clearLocalCache()
public void delete(java.lang.String folderPath)
throws java.io.IOException,
UnlicensedException
folderPath - the folderPath of the file to delete on the SuperContainer server.
java.io.IOException
UnlicensedException
public void deleteLocal(java.io.File localFile)
throws java.io.IOException
localFile - the file to delete.
java.io.IOException - if the file is a directory, or cannot be deleted
public java.io.File download(java.lang.String folderPath,
java.io.File destinationFolderArg,
java.lang.String fileNameOverride,
DownloadParameters parameters,
boolean showProgress,
boolean autoUnzip,
boolean checkIfFileExists,
java.awt.Component nativeFrame)
throws java.io.IOException,
UnlicensedException
java.io.IOException
UnlicensedException
java.io.File getPathToFolderOnServer(java.lang.String macPath,
java.lang.String winPath,
java.lang.String folderPath)
throws java.io.IOException
macPath - Mac OS X path to root SuperContainer storage locationwinPath - Windows to root SuperContainer storage locationfolderPath - The unique identifier for a SuperContainer file
java.io.IOException
public SCResourceInfo getResourceInfo(java.lang.String folderPath)
throws java.io.IOException,
UnlicensedException
folderPath - the folderPath to fetch information about
SCResourceInfo object which contains metadata about the file on the server, or null if there is no resource at the specified folderPath.
java.io.IOException
UnlicensedException
public SCResourceInfo getResourceInfo(java.lang.String folderPath,
MetadataFlags flags)
throws java.io.IOException,
UnlicensedException
folderPath - the folderPath to fetch information aboutflags - flags indicating additional data to get from the server
SCResourceInfo object which contains metadata about the file on the server, or null if there is no resource at the specified folderPath.
java.io.IOException
UnlicensedExceptionpublic java.lang.String getSuperContainerBase()
setBaseUrl(java.lang.String, java.lang.String) function.
http://localhost:8020/SuperContainer/Filespublic java.lang.String getSuperContainerBaseParent()
RawData urls.
http://localhost:8020/SuperContainer
public void move(java.lang.String oldFolderPath,
java.lang.String newFolderPath)
throws java.io.IOException,
UnlicensedException
oldFolderPath - The previous folderPathnewFolderPath - The new folderPath
java.io.IOException
UnlicensedException - when used with incorect registraion info
public void moveLocal(java.io.File sourceFile,
java.io.File destinationFile)
throws java.io.IOException
sourceFile - Original filedestinationFile - File to move source file to!!!FUTURE - - NOT IMPLEMENTED - DO NOT USE!!! overwrite Optional defaults to false, if set, user gets error saying that they can't overwrite file
java.io.IOException - thrown when attemting to write dir to file or if there was a problem moving the file.
public SCResourceInfo resourceInfoFromHeaders(java.util.Map headers,
java.lang.String path,
MetadataFlags flags)
headers - a map of http header names to valuespath - the folderPathflags - optional flags
public java.util.List scanDirectory(java.io.File dir,
boolean recursive)
dir - The local directory to scanrecursive - Whether to recurse into subdirectories
List of Files
public void setBaseUrl(java.lang.String superContainerBase,
java.lang.String sessionId)
throws java.io.IOException
java.io.IOException
public void setBaseUrl(java.lang.String superContainerBase,
java.lang.String username,
java.lang.String password)
throws java.io.IOException
superContainerBase - The base URL where the SuperContainer server is located, e.g. http://localhost:8020/SuperContainer/Filesusername - optional usernamepassword - optional password
InvalidCredentialsException - if the username and password are invalid
java.io.IOException - if there is a communication failure with the server
public void setResource(java.lang.String folderPath,
java.io.File file,
boolean showProgress,
java.awt.Component parent)
throws java.io.IOException,
UnlicensedException
folderPath - The folderpath for the newly uploaded file on SuperContainerfile - the file to uploadshowProgress - whether to display a progress bar during uploadparent - Component to center the progress dialog on (only applicable if showProgress is true)
java.io.IOException
UnlicensedException
public void setResource(java.lang.String folderPath,
java.lang.String fileName,
java.io.InputStream stream,
long length,
boolean showProgress,
java.awt.Component parent,
java.util.Map headers)
throws java.io.IOException,
UnlicensedException
folderPath - The folderpath for the newly uploaded file on SuperContainerfileName - The filename to give the newly uploaded file on SuperContainerstream - Data stream to send to the serverlength - Length of the streamshowProgress - Whether to display a progress dialogparent - Component to center the progress dialog on (only applicable if showProgress is true)headers - optional headers to include
java.io.IOException
UnlicensedException
public void setZipResource(java.lang.String folderPath,
java.lang.String archiveName,
java.io.File[] filesOrDirs,
boolean showProgress,
java.awt.Component parent)
throws java.io.IOException,
UnlicensedException
name and uploading to the indicated folderPath.
folderPath - which path to upload the files toarchiveName - the name of the created zip filefilesOrDirs - the files to upload. These may contain directories.showProgress - whether to show progress barparent - optional parent to center the dialog around
java.io.IOException
UnlicensedException
|
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||